using Microsoft.VisualBasic;
using System.Diagnostics;
using System.Drawing;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Base;
using System.Data.Common;
using System.IO;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using Microsoft.VisualBasic.CompilerServices;
//using DevExpress.XtraGrid.Columns;//added -- JMR -- DEV -- Commented out, already used

namespace ePlanSysOman
{
    public partial class Module1//JMR -- DEV -- changed static to partial
    {
        public static Module1 newModule = new Module1();//JMR

        public string NEWROWACTION = "";
        public bool isNewRow = false;
        public int QN = 0;
        public int QR = 0;
        public string Qseg = "";
        public string wtnewh = "";
        public string wtoldh = "";
        public string WTPL = "";
        public bool ismes = false;
        public System.Threading.Thread Thread1;
        public bool STREDIT = false;
        public bool BNEW = false;
        public OleDbConnection conn = new OleDbConnection();
        public bool repairdb = true;
        public bool Iscarddif = false;
        public string KCLTV = "";
        public int KCLENDS = 0;
        public bool printall = false;
        public xrM1ain report1 = new xrM1ain();
        public xrMain report2 = new xrMain();
        public xrback report3 = new xrback();
        public xrM1ain report4 = new xrM1ain();
        public xrM1ain report5 = new xrM1ain();
        public string exppdf = "";
        public bool isCrunch = false;
        public string newconn = "";
        public bool onlyplugs = false;
        public string ACTFORM = "";
        public int ACTID = 0;
        public string ACTION = "";
        public bool AddWires = false;
        public int AreaNo = 0;
        public string assPlanNumber = "";
        public string AssyDash = "";
        public string assyPartNumber = "";
        public bool BAckhrn = false;
        public bool backshop = false;
        public int CARDELECTRICAL = 0;
        public string CardNumber = "";
        public string Changeaction = "";
        public string ChangeactionNEW = "";
        public string cmbthing = "";
        public string cmbthing2 = "";
        public bool HASCH = false;
        public OleDbConnection Cn = new OleDbConnection();
        public string cname = "";
        public bool comp = false;
        public bool compParts = true;
        public bool CONT;
        public bool contacts = false;
        public int COUNTENDCAPS = 0;
        public int COUNTENDCAPS2 = 0;
        public string CountRefDes = null;
        public string Country = "";
        public int CountryId = 9;
        public OleDbDataAdapter daActions = new OleDbDataAdapter();
        public OleDbDataAdapter daMisc = new OleDbDataAdapter();
        public OleDbDataAdapter daParts = new OleDbDataAdapter();
        public OleDbDataAdapter daRefDes = new OleDbDataAdapter();
        public OleDbDataAdapter daRefDesComp = new OleDbDataAdapter();
        public OleDbDataAdapter daRoute = new OleDbDataAdapter();
        public string dash1 = "";
        public string dash2 = "";
        public int dashl = 0;
        public OleDbDataAdapter daWires = new OleDbDataAdapter();
        public string description = "";
        public bool doNote = false;
        public string DRAWIN = "";
        public string DrwNo = "";
        public string DRWREV = "";
        public DataSet DSPARTS = new DataSet();
        public DataSet DSREIDa = new DataSet();
        public DataSet DSREIDb = new DataSet();
        public DataSet DSREIDENTIFY;
        public string DWGZONE = "";
        public string ecnComment = "";
        public int ECNID = 0;
        public bool Ecns = false;
        public string ECP = "2818";
        public bool EcpParts = false;
        public bool editCard = false;
        public string EFFECTIVITIES;
        public bool electrical = false;
        public string end1 = "";
        public string end2 = "";
        public string EndPoint = "";
        public string ENDPOINTS = "";
        public string ENDPOINTSH = "";
        public bool excist = false;
        public bool flag = false;
        public bool FormCloseex = false;
        public string FORMTEXT = "";
        public int fr = 0;
        public bool FROMELEC = false;
        public bool FROMFILE = false;
        public string GenericCardTitle = "";
        public string harness = "";
        public string HARNESSID = "";
        public string HARNESSPT = "";
        public string HARNESSS = "";
        public string HARNESSSH = "";
        public bool HarnSel = false;
        public bool HASSHIELDS = false;
        public bool hrnDigit = false;
        public string hwd = "";
        public bool isChanged = false;
        public bool isCutOff = false;
        public bool IsLoading = false;
        public bool IsNew = false;
        public bool isOpened = false;
        public bool ISRUNN = false;
        public bool ISRUNN2 = false;
        public bool ISWAFER = false;
        public string length1 = "";
        public bool LoadingForm = false;
        public string LOC = "";
        public string LocWireTie = "";
        public string locWireTie2 = "";
        public bool makewiresb = false;
        public string MISCACTION = "";
        public string MISCPARTNUMBER = "";
        public string MISCREFDES = "";
        public string NAMF = "";
        public string NewDash = "";
        public string NewDWG = "";
        public string newharn = "";
        public string NEWharnCARD = "";
        public string newreidpart = "";
        public int newval = 0;
        public string ni = (Application.StartupPath + "\\Omanmain.mdb");
        public bool NODECLICK = false;
        public string Note = "";
        public string OldDash = "";
        public string OldDRW = "";
        public string oldharn;
        public string oldharnCARD = "";
        public string oldreidpart = "";
        public bool oldSel = false;
        public int oldval;
        public string OLEDB_CONNECTION = "";
        public string OLEDB_CONNECTION_Main = (Application.StartupPath + "\\Omanmain.mdb");
        public bool OpenParts = false;
        public bool ops = false;
        public bool OpsEcn = false;
        public bool opsisopened = false;
        public string partnumber = "";
        public string partsqty = "";
        public string PartsStep = "";
        public string Pin = "";
        public string PIN1 = "";
        public string pin2 = "";
        public string PINS = "";
        public string PINSSH = "";
        public int PLANID = 0;
        public string PlanNumber = "";
        public string plannumber0 = "";
        public string plannumber1 = "";
        public string plannumber2 = "";
        public string planoAgain = "";
        public string PLANTYPE = "";
        public string plnumber = "";
        public string PLUG = "";
        public string PLUG1 = "";
        public string PLUG2 = "";
        public int COUNTPLUG = 0;
        public int COUNTPLUG1 = 0;
        public int COUNTPLUG2 = 0;
        public string ProgramId = "";
        public string refdecount = "";
        public string RefDes = "";
        public string REFDES1 = "";
        public int RefDesId = 0;
        public int refdesidnew = 0;
        public int REFDIDS = 0;
        public int REFDIDSH = 0;
        public string RefWireTie = "";
        public string RefWireTieId = "";
        public bool reid = false;
        public string ResultS = "Obtain the Following Parts from Kit or Bench Stock:";
        public bool ROUTEWIRES = false;
        public bool ROUTEWIRES2 = false;
        public int rowha = 0;
        public int rowhan = 0;
        public string rowt = "";
        public bool sameline = false;
        public string shield = "";
        public string Shields = "";
        public bool simplefile = false;
        public string sRefDes = "";
        public string SREFS = "";
        public string SREFSH = "";
        public bool startAgain = false;
        public bool startinG = false;
        public string stath = "";
        public int StepIncrease;
        public bool STEPWIRESON = false;
        public bool sThing1;
        public bool sThing2;
        public bool sThingSh;
        public bool stpParts = false;
        public string strarea = "";
        public string strEcn = "";
        public string strFrmo = "";
        public int strPlannumber = 0;
        public string STRPLANO = "";
        public string strTHRU = "";
        public bool style = true;
        public bool subsys = false;
        public string subsystem = "";
        public string sWirez = "";
        public string TEAM = "";
        public bool Template = false;
        public string Term = "";
        public string term1 = "";
        public string term2 = "";
        public int TERMCOUN = 0;
        public int TERMCOUN2 = 0;
        public int TERMCOUNT4 = 0;
        public int TERMCOUNT5 = 0;
        public int TERMCOUNT6 = 0;
        public string TerminalCount = "";
        public string TERMNAME = null;
        public string TERMNAME2 = null;
        public string TERMNAME4 = null;
        public string TERMNAME5 = null;
        public string TERMNAME6 = null;
        public string TERMSH = "";
        public string TITLE = "";
        public int totalContacts = 0;
        public int trhu = 0;
        public string tv = "";
        public string udl = (Application.StartupPath + "\\test.udl");
        public bool unknown = false;
        public bool waic = false;
        public string wireno1 = "";
        public string WireNo2 = "";
        public string WIRES = "";
        public string WIRESH = "";
        public string WireSpec = "";
        public bool wt = false;
        public int wtcount = 0;

        public string docHandling = "";
        public string NewHarnessPTP = "";
        public string OldHarnessPTP = "";

        public string TypeVer = "";
        public int FRMO = 0;
        public int THRU = 0;

        public string TailNo = "";
        public int effStarts = 0;
        public bool RELAS = false;

        public int effEnds = 0;

        public static frmMain start = new frmMain();

        public void addNewRowInGroupMode (GridView View) 
        {
            int num2 = 0;
            int dataRowHandleByGroupRowHandle = View.GetDataRowHandleByGroupRowHandle(View.FocusedRowHandle);
            object[] objArray = null;
            int num = View.GroupedColumns.Count;
            int index = 0;
            if ((num > 0))
            {
                index = (((num - 1) + 1) - 1);
                objArray[index] = new object
                {

                };
                int num5 = (num - 1);
                num2 = 0;
                while ((num2 <= num5))
                {
                    //JMR --https://documentation.devexpress.com/#windowsforms/DevExpressXtraGridColumnsGridColumnReadOnlyCollection_Itemtopic
                    objArray[num2] = (View.GetRowCellValue(dataRowHandleByGroupRowHandle, View.GroupedColumns[num2]));
                    //objArray[num2] = (View.GetRowCellValue(dataRowHandleByGroupRowHandle, View.GroupedColumns.);
                    num2 += 1;
                }
            }
            try
            {
                View.AddNewRow();
                int focusedRowHandle = View.FocusedRowHandle;
                object objectValue = View.GetRow(focusedRowHandle);
                if ((num > 0))
                {
                    int num6 = (num - 1);
                    num2 = 0;
                    while ((num2 <= num6))
                    {
                        View.SetRowCellValue(focusedRowHandle, View.GroupedColumns[num2], (objArray[num2]));                        
                        num2 += 1;
                    }
                }
                View.UpdateCurrentRow();
                //Dim dataRowCount As Integer = View.DataRowCount
                //num2 = 0
                //Do While (num2 <= dataRowCount)
                //    If View.GetRow(num2).Equals((objectValue)) Then
                //        View.FocusedRowHandle = num2
                //        Return
                //    End If
                //    num2 += 1
                //Loop
            }
            catch (Exception exception1)
            {


            }
        }
        public void expanx(GridView grdview)
        {
            object ass = grdview.PressedColumn;
            GridHitInfo asd;
            System.Drawing.Point pt = grdview.GridControl.PointToClient(Control.MousePosition);
            asd = grdview.CalcHitInfo(pt);
            if (GridHitTest.RowGroupButton == asd.HitTest)
            {
            }
            else
            {
                bool EXT = false;
                EXT = grdview.GetRowExpanded(grdview.FocusedRowHandle);

                if (EXT == true)
                {
                    EXT = false;
                }
                else
                {
                    EXT = true;
                }
                // ReworkView.SetRowExpanded(ReworkView.FocusedRowHandle - 1, EXT)
                grdview.SetRowExpanded(grdview.FocusedRowHandle, EXT);
            }

        }
        public void ClearCard(string CardNo)
        {
            clsData data = new clsData();
            data.ExecuteSQL(("DELETE * FROM PDFWIREs WHERE term = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM PDFWIRE1 WHERE pdfplid1 = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM PDFWIRE2 WHERE pdfplid2 = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLASSEMBLY WHERE prtPlid = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLBACKSHOPWIRES WHERE bacPlId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLCONT WHERE bacPlId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLDRAWINGS WHERE DwgPlId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLMISC WHERE MISCPLANID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLNOTES WHERE  plNotesId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLPARTS WHERE PARTSPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLPARTSCONSUM WHERE conPlId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE RefPlanId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLREFDESCOMP WHERE REFCOMPPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLROUTE WHERE  rPlId= '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLTEMPLATE WHERE tmpPlid = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLTOOLS WHERE tlPlid = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLWIRES WHERE WIRESPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLHARNESS WHERE HPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLEFFECTIVITIES WHERE efPlId = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLWIRESREMOVE WHERE WIRESPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLWIRESADD WHERE WIRESPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLWIRESREVISE WHERE WIRESPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM tblWiresBackshell WHERE WIRESPLID = '" + CardNo + "'"));
            data.ExecuteSQL(("DELETE * FROM TBLselHARNESS WHERE hrnSelPlId = '" + CardNo + "'"));
        }

        //Public Function GetSelectedValues(ByVal View As GridView) As String
        //    If View.SelectedRowsCount = 0 Then Return ""
        //    Dim rowCellDisplayText As String
        //    Const CellDelimiter As String = vbTab
        //    Const LineDelimiter As String = vbCrLf
        //    Dim cellv As String
        //    Dim Result As String = "Obtain the Following Parts from Kit or Bench Stock:"
        //    Result += LineDelimiter
        //    If ops = True Then
        //        Result += "QTY     ACTION    DWZONE    PART NUMBER       DESCRIPTION"
        //        Result += LineDelimiter
        //    End If
        //    If electrical = True Then
        //        Result += "QTY  PART NUMBER       DESCRIPTION                 LOCATION    ACTION"
        //        Result += LineDelimiter
        //    End If
        //    If wt = True Then
        //        rowCellDisplayText = View.GetRowCellDisplayText(View.GetSelectedRows(0), "WIRE_END_REF")
        //        Result = ("Locate wire tie near " & Module1.LocWireTie & ".  ")
        //    End If

        //    ' iterate cells and compose a tab delimited string of cell values
        //    Dim I, J As Integer
        //    Dim Row As Integer
        //    Dim Gui As String
        //    Dim str6 As String

        //    Dim num19 As Integer
        //    PartsStep = Nothing
        //    Dim leng As Integer
        //    Dim current As String
        //    Dim k As Integer
        //    Do While (I <= num8)
        //        Dim str As String
        //        Dim str2 As String
        //        Dim num3 As Integer
        //        If Module1.electrical Then
        //            str = (View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Length)
        //            str2 = View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Trim
        //            str6 = (str6 & View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Trim)
        //        Else
        //            str = (View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Length)
        //            str2 = View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Trim
        //            str6 = (str6 & View.GetRowCellDisplayText(rowHandle, View.VisibleColumns.Item(I)).Trim)
        //        End If
        //        Dim length As Integer = str2.Length
        //        If Module1.ops Then
        //            Select Case I
        //                Case 0
        //                    Dim num9 As Integer = (7 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num9)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 1
        //                    Dim num10 As Integer = (9 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num10)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 2
        //                    Dim num11 As Integer = (9 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num11)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 3
        //                    Dim num12 As Integer = (&H11 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num12)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 4
        //                    Dim num13 As Integer = (&H11 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num13)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //            End Select
        //        End If
        //        If Module1.electrical Then
        //            Select Case I
        //                Case 0
        //                    Dim num14 As Integer = (4 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num14)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 1
        //                    Dim num15 As Integer = (&H11 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num15)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 2
        //                    Dim num16 As Integer = (&H1B - length)
        //                    num3 = 0
        //                    Do While (num3 <= num16)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 3
        //                    Dim num17 As Integer = (11 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num17)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //                Case 4
        //                    Dim num18 As Integer = (6 - length)
        //                    num3 = 0
        //                    Do While (num3 <= num18)
        //                        str6 = (str6 & " ")
        //                        num3 += 1
        //                    Loop
        //                    Exit Select
        //            End Select
        //        End If
        //        I += 1
        //    Loop
        //    'For I = View.SelectedRowsCount - 1 To 0 Step -1
        //    '    Row = View.GetSelectedRows()(I)
        //    '    For J = 0 To View.VisibleColumns.Count - 1
        //    '        cellv = View.GetRowCellDisplayText(Row, View.VisibleColumns(J)).Length

        //    '        Result += View.GetRowCellDisplayText(Row, View.VisibleColumns(J))
        //    '        current = View.GetRowCellDisplayText(Row, View.VisibleColumns(J))
        //    '        leng = current.Length
        //    '        '        If ops = True Then
        //    '        '            If J = 0 Then
        //    '        '                For k = 0 To (7 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 1 Then
        //    '        '                For k = 0 To (9 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 2 Then
        //    '        '                For k = 0 To (9 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 3 Then
        //    '        '                For k = 0 To (25 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 4 Then
        //    '        '                For k = 0 To (9 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If

        //    '        '        End If
        //    '        '        If electrical = True Then

        //    '        '            If J = 0 Then
        //    '        '                For k = 0 To (4 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 1 Then
        //    '        '                For k = 0 To (17 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 2 Then
        //    '        '                For k = 0 To (17 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 3 Then
        //    '        '                For k = 0 To (13 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If
        //    '        '            If J = 4 Then
        //    '        '                For k = 0 To (6 - leng)
        //    '        '                    Result += " "
        //    '        '                Next
        //    '        '            End If


        //    '        '        End If
        //    '        If Module1.ops Then
        //    '            Select Case I
        //    '                Case 0
        //    '                    Dim num9 As Integer = (7 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num9)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 1
        //    '                    Dim num10 As Integer = (9 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num10)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 2
        //    '                    Dim num11 As Integer = (9 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num11)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 3
        //    '                    Dim num12 As Integer = (&H11 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num12)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 4
        //    '                    Dim num13 As Integer = (&H11 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num13)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '            End Select
        //    '        End If
        //    '        If Module1.electrical Then
        //    '            Select Case I
        //    '                Case 0
        //    '                    Dim num14 As Integer = (4 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num14)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 1
        //    '                    Dim num15 As Integer = (&H11 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num15)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 2
        //    '                    Dim num16 As Integer = (&H1B - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num16)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 3
        //    '                    Dim num17 As Integer = (11 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num17)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '                Case 4
        //    '                    Dim num18 As Integer = (6 - length)
        //    '                    num3 = 0
        //    '                    Do While (num3 <= num18)
        //    '                        str6 = (str6 & " ")
        //    '                        num3 += 1
        //    '                    Loop
        //    '                    Exit Select
        //    '            End Select
        //    '        End If
        //    '        I += 1

        //    '    Next
        //    '    If I <> 0 Then
        //    '        Result += LineDelimiter
        //    '    End If
        //    'Next

        //    If Module1.wt Then
        //        Dim dsf As New DataSet
        //        Dim dfc As New clsData

        //        dsf = dfc.getData(String.Concat(New String() {"SELECT * FROM TBLREFDESCOMP WHERE REFACTION ='ADD' AND REFCOMPPLID ='", Module1.plnumber, "' and LOCATION = '", Module1.RefWireTie, "'"}))
        //        If dsf.Tables.Item(0).Rows.Count = 0 Then
        //            Result = "No part for this wire tie on parts list.  Add parts on list or check if wire tie not reworked."
        //        Else
        //            Dim set2 As New DataSet
        //            If (dfc.getData(String.Concat(New String() {"SELECT * FROM PTP WHERE  PART_NUMBER ='", Module1.oldharn, "' AND WIRE_END_REF ='", Module1.RefWireTie, "'"})).Tables.Item(0).Rows.Count = 0) Then
        //                rowCellDisplayText = ("Install new wire tie " & Module1.RefWireTie & ", part number " & dsf.Tables.Item(0).Rows.Item(0).Item("PARTNUMBER")) & ", on the wires listed in the table below. "
        //            End If
        //        End If
        //    End If
        //    PartsStep = Result.ToCharArray

        //    Return Result

        //End Function
        public string GetSelectedValues(GridView View)
        {
            ;
            string str6 = "";//JMR -- look at -- nulled it
            string rowCellDisplayText;
            int num19;
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            if ((View.SelectedRowsCount == 0))
            {
                return "";
            }
            str6 = (str6 + thirteen + ten);
            if (newModule.ops)
            {
                str6 = "Obtain the Following Parts from Kit or Bench Stock:";
                str6 = ((str6 + thirteen + ten + thirteen + ten) + "QTY     ACTION    DWZONE    PART NUMBER       DESCRIPTION" + thirteen + ten + thirteen + ten);
            }
            else if (newModule.electrical)
            {
                str6 = "Obtain the Following Parts from Kit or Bench Stock:";
                str6 = ((str6 + thirteen + ten + thirteen + ten) + "QTY  PART NUMBER       DESCRIPTION                 LOCATION    ACTION" + thirteen + ten + thirteen + ten);
            }
            else if (newModule.wt)
            {
                rowCellDisplayText = View.GetRowCellDisplayText(View.GetSelectedRows()[0], "WIRE_END_REF");//JMR
                str6 = ("Locate wire tie near " + newModule.LocWireTie + ".  ");
            }
            newModule.PartsStep = null;
            DataSet aset = new DataSet();
            clsData data = new clsData();
            int index = (View.SelectedRowsCount - 1);
        Label_049C:
            num19 = 0;
            if ((index >= num19))
            {
                int rowHandle = View.GetSelectedRows()[index];//JMR
                //int ranNum = Conversions.ToInteger(View.GetSelectedRows());  //JMR this works though, but doesn't accept value index


                if (!newModule.wt)
                {
                    int num8 = (View.VisibleColumns.Count - 1);
                    int i = 0;
                    while ((i <= num8))
                    {
                        string str;//JMR str is being set to different things but never seems to be actually called/shown if the actual program
                        string str2;
                        int num3;
                        if (newModule.electrical)
                        {
                            str = (View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Length.ToString());
                            str2 = View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Trim();
                            //JMR
                            if (str2.Contains("TUBING") && str.Length > 25)
                            {
                                str2 = str2.Substring(0, str2.Length - 6).Trim();
                                str = str2.Length.ToString();//JMR -- Converted to string
                                str6 = str6 + str2;
                            }
                            else
                            {
                                str6 = (str6 + View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Trim());

                            }
                        }
                        else
                        {
                            str = (View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Length.ToString());
                            str2 = View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Trim();
                            if (i < 5)
                            {
                                str6 = (str6 + View.GetRowCellDisplayText(rowHandle, View.VisibleColumns[i]).Trim());                                

                            }
                        }
                        int length = str2.Length;
                        if (newModule.ops)
                        {
                            switch (i)
                            {
                                case 0:
                                    int num9 = (7 - length);
                                    num3 = 0;
                                    while ((num3 <= num9))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 1:
                                    int num10 = (9 - length);
                                    num3 = 0;
                                    while ((num3 <= num10))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 2:
                                    int num11 = (9 - length);
                                    num3 = 0;
                                    while ((num3 <= num11))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 3:
                                    int num12 = (0x11 - length);
                                    num3 = 0;
                                    while ((num3 <= num12))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 4:
                                    int num13 = (0x11 - length);
                                    num3 = 0;
                                    while ((num3 <= num13))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                            }
                        }
                        //If Module1.ops Then
                        //    Select Case i
                        //        Case 0
                        //            Dim num9 As Integer = (7 - length)
                        //            num3 = 0
                        //            Do While (num3 <= num9)
                        //                str6 = (str6 & " ")
                        //                num3 += 1
                        //            Loop
                        //            Exit Select
                        //        Case 1
                        //            Dim num10 As Integer = (9 - length)
                        //            num3 = 0
                        //            Do While (num3 <= num10)
                        //                str6 = (str6 & " ")
                        //                num3 += 1
                        //            Loop
                        //            Exit Select
                        //        Case 2
                        //            Dim num11 As Integer = (9 - length)
                        //            num3 = 0
                        //            Do While (num3 <= num11)
                        //                str6 = (str6 & " ")
                        //                num3 += 1
                        //            Loop
                        //            Exit Select
                        //        Case 3
                        //            Dim num12 As Integer = (&H11 - length)
                        //            num3 = 0
                        //            Do While (num3 <= num12)
                        //                str6 = (str6 & " ")
                        //                num3 += 1
                        //            Loop
                        //            Exit Select
                        //        Case 4
                        //            Dim num13 As Integer = (&H11 - length)
                        //            num3 = 0
                        //            Do While (num3 <= num13)
                        //                str6 = (str6 & " ")
                        //                num3 += 1
                        //            Loop
                        //            Exit Select
                        //    End Select
                        //End If
                        if (newModule.electrical)
                        {
                            switch (i)
                            {
                                case 0:
                                    int num14 = (4 - length);
                                    num3 = 0;
                                    while ((num3 <= num14))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 1:
                                    int num15 = (0x11 - length);
                                    num3 = 0;
                                    while ((num3 <= num15))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 2:
                                    int num16 = (0x1b - length);
                                    num3 = 0;
                                    while ((num3 <= num16))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 3:
                                    int num17 = (11 - length);
                                    num3 = 0;
                                    while ((num3 <= num17))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                                case 4:
                                    int num18 = (6 - length);
                                    num3 = 0;
                                    while ((num3 <= num18))
                                    {
                                        str6 = (str6 + " ");
                                        num3 += 1;
                                    }
                                    break; // TODO: might not be correct. Was : Exit Select

                            }
                        }
                        i += 1;
                    }
                    if (newModule.electrical)
                    {
                    }
                }
                if ((!newModule.wt && (index != 0)))
                {
                    str6 = (str6 + thirteen + ten);
                }
                index = (index + -1);
                goto Label_049C;
            }
            if (newModule.wt)
            {
                aset = data.getData(string.Concat(new string[] {
          "SELECT * FROM TBLREFDESCOMP WHERE REFACTION ='ADD' AND REFCOMPPLID ='",
          newModule.plnumber,
          "' and LOCATION = '",
          newModule.RefWireTie,
          "'"
        }));
                if ((aset.Tables[0].Rows.Count == 0))
                {
                    str6 = "No part for this wire tie on parts list.  Add parts on list or check if wire tie not reworked.";
                }
                else
                {
                    DataSet set2 = new DataSet();
                    if ((data.getData(string.Concat(new string[] {
            "SELECT * FROM PTP WHERE  PART_NUMBER ='",
            newModule.oldharn,
            "' AND WIRE_END_REF ='",
            newModule.RefWireTie,
            "'"
          })).Tables[0].Rows.Count == 0))
                    {
                        rowCellDisplayText = (Operators.AddObject(("Install new wire tie " + Module1.newModule.RefWireTie + ", part number "), aset.Tables[0].Rows[0]["PARTNUMBER"])) + ", on the wires listed in the table below. ";
                        str6 = (str6 + rowCellDisplayText);
                    }
                }
            }
            newModule.PartsStep = new string(str6.ToCharArray());//JMR -- look at -- changed string.str6.ToCharArray to str6.ToCharArray()
            return str6;
        }

        public DataSet Createadapter(DataSet ds, string tblName, string where, ref OleDbDataAdapter da)//JMR
        {
            InitConnection();
            if ((where == "*"))
            {
                da = new OleDbDataAdapter(("select * from " + tblName), newModule.Cn.ConnectionString);//JMR
            }
            else if ((where == "Q"))
            {
                da = new OleDbDataAdapter(("select * from " + tblName + " WHERE 1 = 2"), newModule.Cn.ConnectionString);//JMR
            }
            else
            {
                da = new OleDbDataAdapter(("select * from " + tblName + " where " + where), newModule.Cn.ConnectionString);//JMR
            }

            OleDbCommandBuilder csq = new OleDbCommandBuilder(da);//JMR


            da.MissingSchemaAction = MissingSchemaAction.AddWithKey;

            da.InsertCommand = csq.GetInsertCommand();
            da.UpdateCommand = csq.GetUpdateCommand();
            da.DeleteCommand = csq.GetDeleteCommand();
            try
            {
                da.Fill(ds, tblName);
            }
            catch (Exception ex)
            {

            }

            return ds;
        }
        /*public DataSet fillNetwork(string PREFDES)
        {

          if (IsNew) {

          } else if (isCutOff) {
          } else {

          }
        }

        public DataSet fillCB(string PREFDES)
        {
          if (IsNew) {

          } else if (isCutOff) {
          } else {

          }
        }

        public DataSet fillConnector(string PREFDES)
        {
          if (IsNew) {

          } else if (isCutOff) {
          } else {

          }
        }
        public DataSet fillGDSOCKET(string PREFDES)
        {
          if (IsNew) {

          } else if (isCutOff) {
          } else {

          }
        }*/
        public void AddRow(DevExpress.XtraGrid.Views.Grid.GridView View)
        {
            int currentRow;
            currentRow = View.FocusedRowHandle;
            //DevExpress.XtraGrid.Columns.GridColumn groupColumn; //JMR
            if (currentRow < 0)
            {
                currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow);
            }
            else
            {
                //currentRow = -1
                //currentRow = View.DataRowCount + 1
                //currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow)
            }
            if (isNewRow)
            {
                foreach (DevExpress.XtraGrid.Columns.GridColumn groupColumn in View.GroupedColumns)
                {
                    NEWROWACTION = View.GetRowCellValue(currentRow, groupColumn).ToString();//JMR
                }
                View.FocusedRowHandle = -2147483647;
            }
            else
            {
                View.AddNewRow();
            }


            if (View.GroupedColumns.Count == 0)
            {
                return;
            }


            // Initialize group values

            foreach (DevExpress.XtraGrid.Columns.GridColumn groupColumn in View.GroupedColumns)
            {
                object value = View.GetRowCellValue(currentRow, groupColumn);
                //If value Is DBNull.Value Then
                //    value = "ADD"
                //    '    groupColumn.Name = "REFACTION"
                //End If
                if (isNewRow)
                {
                    currentRow = -2147483647;
                    View.SetRowCellValue(currentRow, groupColumn, value);
                }
                else
                {
                    View.SetRowCellValue(View.FocusedRowHandle, groupColumn, value);
                }


            }
            //  View.UpdateCurrentRow()

            //View.UpdateCurrentRow()
            if (isNewRow == true)
            {
                isNewRow = false;
            }
            else
            {
                View.MakeRowVisible(View.FocusedRowHandle, true);
                View.ShowEditor();
            }

        }

        [STAThread]public static void Main2()
        {
            //Application.EnableVisualStyles()
            //Application.SetCompatibleTextRenderingDefault(False)
            //'DevExpress.UserSkins.OfficeSkins.Register()
            //'DevExpress.UserSkins.BonusSkins.Register()
            //DevExpress.Skins.SkinManager.EnableFormSkins()
            //'ChangeMDIColor()

            //If Not CheckSecurity() Then
            //    MessageBoxEx.Show("Δεν έχει ενεργοποιηθεί η άδεια χρήσης της εφαρμογής.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
            //    Exit Sub
            //End If
            //frmConnection frmConn = new frmConnection();
            //try
            //{
            //    if (frmConn.ConnectToServer())
            //    {
            //        //If GetParameters() Then 
            //        frmConn.Dispose();
            //        //Application.Run(frmMain)
            //        //Else
            //        //    Application.Exit()
            //        //End If
            //    }
            //    else
            //    {
            //        frmConn.Dispose();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    frmConn.Dispose();
            //    //XtraMessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)

            //    Application.Exit();
            //}

            try
            {
                if (frmMain.frmConn.ConnectToServer())
                {
                    //If GetParameters() Then 
                    frmMain.frmConn.Dispose();
                    //Application.Run(frmMain)
                    //Else
                    //    Application.Exit()
                    //End If
                }
                else
                {
                    frmMain.frmConn.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Hey Jared, its me Brandon");
                frmMain.frmConn.Dispose();
                //XtraMessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)

                System.Windows.Forms.Application.Exit();
            } 

            //object sender = new object();
            //System.EventArgs e = new System.EventArgs();


            //try
            //{
            //    start.frmMain_Load(sender, e);
            //    //Application.Run(frmMain.start);
            //}
            //catch(Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Hey Jared, its me Brandon");
            //}
        }

        public void fillNewHarness(DevExpress.XtraGrid.GridControl grid)
        {

            DataSet dsr = new DataSet();
            clsData dct = new clsData();
            dsr = dct.getData("select * from PTP where PART_NUMBER ='" + NewHarnessPTP + "'");
            grid.DataSource = dsr.Tables[0];
            grid.Refresh();



        }

        public void fillOldHarness(DevExpress.XtraGrid.GridControl grid, string harnd, string oldharnd)
        {

            DataSet dsr = new DataSet();
            clsData dct = new clsData();
            dsr = dct.getData("select * from PTP where PART_NUMBER ='" + harnd + "' or PART_NUMBER ='" + oldharnd + "'");
            grid.DataSource = dsr.Tables[0];
            grid.Refresh();


        }

        public bool DeleteSelectedRows(GridView view)
        {

            int num3;
            if (view.Name == "GridView27")
            {
                if ((view.SelectedRowsCount == 0))
                {
                    return true;
                }
                int index = (view.SelectedRowsCount - 1);
            Label_016E:
                num3 = 0;
                if ((index >= num3))
                {
                    int rowHandle = view.GetSelectedRows()[index];//JMR
                    string str2 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[4]).Trim();
                    string str = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[3]).Trim();
                    string str4 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[2]).Trim();
                    string str3 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[5]).Trim();
                    clsData data = new clsData();
                    if (str == "ADD")
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwiresADD where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));


                    }

                    if (str == "REMOVE")
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwiresREMOVE where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));
                    }


                    data.ExecuteSQL(string.Concat(new string[] {
            "delete * from tblwires where wireactid ='",
            str,
            "' and  WIRENO ='",
            str4,
            "' AND PIN ='",
            str2,
            "' and srefdes ='",
            str3,
            "'"
          }));
                    data.ExecuteSQL(string.Concat(new string[] {
            "delete * from tblwires",
            str,
            " where WIRENO ='",
            str4,
            "' AND PIN ='",
            str2,
            "' and srefdes ='",
            str3,
            "'"
          }));
                    index = (index + -1);
                    goto Label_016E;
                }
            }
            if (view.Name == "grdWiresView")
            {
                if ((view.SelectedRowsCount == 0))
                {
                    return true;
                }
                int index2 = (view.SelectedRowsCount - 1);
            Label_016E2:
                num3 = 0;
                if ((index2 >= num3))
                {
                    int rowHandle = view.GetSelectedRows()[index2];// JMR
                    string str2 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[2]).Trim();
                    string str = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[0]).Trim();
                    string str4 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[4]).Trim();
                    string str3 = view.GetRowCellDisplayText(rowHandle, view.VisibleColumns[1]).Trim();
                    clsData data = new clsData();
                    if (str == "ADD")
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwiresADD where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));


                    }

                    if (str == "REMOVE")
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwiresREMOVE where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));
                    }
                    data.ExecuteSQL(string.Concat(new string[] {
            "delete * from tblBackShopWires where bacAction ='",
            str,
            "' and  bacWireNo ='",
            str4,
            "' AND bacPin1 ='",
            str2,
            "' and bacRefdes1 ='",
            str3,
            "'"
          }));
                    if (str3.Contains("WT"))
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwires where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' and srefdes ='",
              str3,
              "'"
            }));
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwires",
              str,
              " where WIRENO ='",
              str4,
              "' and srefdes ='",
              str3,
              "'"
            }));
                    }
                    else
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwires where wireactid ='",
              str,
              "' and  WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));
                        data.ExecuteSQL(string.Concat(new string[] {
              "delete * from tblwires",
              str,
              " where WIRENO ='",
              str4,
              "' AND PIN ='",
              str2,
              "' and srefdes ='",
              str3,
              "'"
            }));
                    }

                    index2 = (index2 + -1);
                    goto Label_016E2;
                }
            }
            return flag;
        }

        public bool InitConnection()
        {
            if (repairdb == true)
            {
                repairdb = false;
                try
                {
                    JRO.JetEngine jro = new JRO.JetEngine();
                    frmMain.frmConn.label3.Text = "Connecting to Database . . . . . ";
                    frmMain.frmConn.label3.Refresh();
                    Application.DoEvents();
                    jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Omanmain.mdb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Omanmainrp.mdb ;Jet OLEDB:Engine Type=5");

                    File.Delete(Application.StartupPath + "\\Omanmain.mdb");//JMR
                    File.Move(Application.StartupPath + "\\Omanmainrp.mdb", "Omanmain.mdb");//JMR
                    //My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\\Omanmain.mdb");
                    //My.Computer.FileSystem.RenameFile(Application.StartupPath + "\\Omanmainrp.mdb", "Omanmain.mdb");
                }
                catch (Exception ex)
                {
                    repairdb = false;
                }
            }

            try
            {



                string strConn;



                if (isCrunch == true)
                {
                    strConn = "Provider = Microsoft.Jet.OLEDB.4.0;";
                    strConn += "Data Source = " + newconn;
                    conn = new OleDbConnection(strConn);
                    // conn.Open()
                }
                else
                {
                    strConn = "Provider = Microsoft.Jet.OLEDB.4.0;";
                    strConn += "Data Source = " + Application.StartupPath + "\\Omanmain.mdb";
                    conn = new OleDbConnection(strConn);
                }




                //'Cn = New OleDb.OleDbConnection(OLEDB_CONNECTION_Main)
                //OLEDB_CONNECTION = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source= C:\Program Files (x86)\ePlanSys\Omanmain.mdb;Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider='Microsoft.Jet.OLEDB.4.0';Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Jet OLEDB:Database Password=urwdw;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
                //Cn = New OleDb.OleDbConnection(OLEDB_CONNECTION)

                Cn = conn;
                //conn.Open()

                return true;

            }
            catch (Exception e)
            {
                frmConnection frmConn = new frmConnection();
                System.Environment.Exit(0);
                MessageBox.Show(e.Message.ToString() + "Open test.udl ,on application folder under Programfiles/ePlansys,browse for Omanmain that is on the same folder test connection and apply", "Connection Error...", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                System.Environment.Exit(0);
                frmConn.Dispose();
                return false;

            }
            //' ''Try

            //' ''    Cn = New OleDb.OleDbConnection(OLEDB_CONNECTION_Main)
            //' ''    OLEDB_CONNECTION = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source='" + Cn.DataSource.ToString + "';Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider='Microsoft.Jet.OLEDB.4.0';Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Jet OLEDB:Database Password=urwdw;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
            //' ''    Cn = New OleDb.OleDbConnection(OLEDB_CONNECTION)


            //' ''    Cn.Open()

            //' ''    Return True

            //' ''Catch e As Exception
            //' ''    Dim frmConn As frmConnection = New frmConnection
            //' ''    XtraMessageBox.Show(e.Message.ToString() + "Open test.udl ,on application folder under Programfiles/ePlansys,browse for Omanmain that is on the same folder test connection and apply", "Connection Error...", MessageBoxButtons.OK, MessageBoxIcon.Stop)


            //' ''    frmConn.Dispose()
            //' ''    Return False

            //' ''End Try



        }

    }
}

